package com.shujia.spark.stream

import com.alibaba.fastjson.{JSON, JSONObject}

import java.lang

object Demo8Json {
  def main(args: Array[String]): Unit = {
    //json字符串
    val jsonStr: String =
      """
        |{"car":"皖A9A7N2","city_code":"340500","county_code":"340522","card":117988031603010,"camera_id":"00001","orientation":"西南","road_id":34052055,"time":1614711895,"speed":36.38}
        |""".stripMargin

    //使用fastjson工具解析jso字符串
    val jsonObj: JSONObject = JSON.parseObject(jsonStr)

    //通过json中的key获取alue
    val card: Long = jsonObj.getLong("card")
    val speed: Double = jsonObj.getDouble("speed")

    println(card)
    println(speed)


  }

}
